package com.zzxz.practicaltrainingsys.service.impl;

import com.zzxz.practicaltrainingsys.entity.Adm;
import com.zzxz.practicaltrainingsys.mapper.AdmMapper;
import com.zzxz.practicaltrainingsys.service.AdmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdmServiceImpl implements AdmService {
    @Autowired
    private AdmMapper admMapper;

    @Override
    public List<Adm> queryAllAdm() {
        return admMapper.queryAllAdm();
    }

    @Override
    public Adm getAdmById(Integer id) {
        return admMapper.getAdmById(id);
    }

    @Override
    public int insertAdm(Adm adm) {
        // 新增管理员默认为启用状态
        if (adm.getAdmin_state() == null) {
            adm.setAdmin_state("正常");
        }
        return admMapper.insertAdm(adm);
    }

    @Override
    public int updateAdm(Adm adm) {
        return admMapper.updateAdm(adm);
    }

    @Override
    public Adm getAdmByPhone(String phone) {
        return admMapper.getAdmByPhone(phone);
    }

    @Override
    public int updateAdmStatus(Integer admin_id) {
        return admMapper.updateAdmStatus(admin_id);
    }


}